let ming = {
    name: "小明",
    age: 15,
    girlFriend: {
        name: "小红",
        age: 14,
        eat(){
            console.log("吃",this)
        }
    },
    sleep(){
        console.log("睡觉",this)
    }
}

function deepCopy(obj,set= new Set()){
    if(obj == null) return null
    // if(obj instanceof Number ) return new Number()
    if(set.has(obj)) return obj
    set.add(obj)

    let target = {}

    for(prop in obj){
        switch(typeof(obj[prop])){
            // 这里没有case null ，因为typeof(null) 返回的是 object 时，往往被认为是空对象引用
            case "string":
            case "number":
            case "boolean":
            case "undefined":{
                target[prop] = obj[prop]
            }break;
            case "function":{
                target[prop] = obj[prop].bind(target)
            }break;
            case "object":{
                target[prop] = deepCopy(obj[prop],set)
            }break;
            default: break;
        }
    }
    return target
}